package edu.thu.thss.yxy.sip.event;

import java.util.EventObject;

import edu.thu.thss.yxy.sip.Call;
import edu.thu.thss.yxy.sip.CallState;

public class CallStateEvent extends EventObject {
	/* New value for property. May be null if not known. */
	private CallState newState;
	/* Previous value for property. May be null if not known. */
	private CallState oldState;
	
	public CallStateEvent(Call source) {
		super(source);
	}
	
	/**
     * Creates a CallChangeEvent with the specified source, type, oldValue and
     * newValue.
     * @param source the peer that produced the event.
     * @param oldValue the value of the changed property before the event
     * occurred
     * @param newValue current value of the changed property.
     */
    public CallStateEvent(Call source,CallState oldValue, CallState newValue)
    {
        super(source);
        this.oldState = oldValue;
        this.newState = newValue;
    }
    
    /**
	 * Sets the new value for the property, expressed as an Object.
	 * 
	 * @return The new value for the property, expressed as an Object. May be
	 *         null if multiple properties have changed.
	 */
	public CallState getNewState() {
		return newState;
	}

	/**
	 * Gets the old value for the property, expressed as an Object.
	 * 
	 * @return The old value for the property, expressed as an Object. May be
	 *         null if multiple properties have changed.
	 */
	public CallState getOldState() {
		return oldState;
	}
	/**
     * The Call on which the event has occurred.
     *
     * @return   The Call on which the event has occurred.
     */
    public Call getSourceCall()
    {
        return (Call)getSource();
    }
}
